require('./js/libs/weapp-adapter')
const screenWidth = window.innerWidth
const screenHeight = window.innerHeight

var canvas = wx.createCanvas();
var context = canvas.getContext('2d');
context.fillStyle = 'red';
context.fillRect(0, 0, canvas.width, canvas.height);


var bgImage = wx.createImage();
bgImage.src = './images/bg.jpg';
bgImage.onload = function () {
  console.log(bgImage.width, bgImage.height)
  // context.drawImage(bgImage, 0, 0)
};

/*
var screenCanvas = wx.createCanvas();
var offScreenCanvas = wx.createCanvas();
var offContext = offScreenCanvas.getContext('2d');
offContext.fillStyle = 'red';
offContext.fillRect(0, 0, 100, 100);
var screenContext = screenCanvas.getContext('2d')
screenContext.drawImage(offScreenCanvas, 0, 0)
*/

console.log(Math.round(Math.random() * 12 + 1));//生成1-13的随机数
console.log(Math.round(Math.random() * 3 + 0));//生成0-3的随机数

var suit = ['diamond','club','heart','spade'];
var suit1 = suit[Math.round(Math.random() * 3 + 0)];
var suit2 = suit[Math.round(Math.random() * 3 + 0)];
var suit3 = suit[Math.round(Math.random() * 3 + 0)];
var suit4 = suit[Math.round(Math.random() * 3 + 0)];
var point1 = Math.round(Math.random() * 12 + 1);
var point2 = Math.round(Math.random() * 12 + 1);
var point3 = Math.round(Math.random() * 12 + 1);
var point4 = Math.round(Math.random() * 12 + 1);
var givenPokers = [];
givenPokers.concat(suit1 + '_' + point1);
givenPokers.concat(suit2 + '_' + point2);
givenPokers.concat(suit3 + '_' + point3);
givenPokers.concat(suit4 + '_' + point4);

let image1 = wx.createImage();
image1.src = './images/' + suit1 + '_' + point1+'.jpg';

image1.onload = function () {
  context.drawImage(image1, 2, 50);
  console.log(image1);
};